<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
			this.getMsgCount()
		},
		onHide: function() {
			console.log('App Hide')
		},
		onPageNotFound: function (){
			uni.navigateTo({
				url: '/pages/notFound/index'
			})
		},
		methods: {
			// 获取未读消息条数
			getMsgCount (){
				const access_token = uni.getStorageSync('access_token')
				if(!access_token) {
					return false
				}
				this.$request.get('/message/count?accesstoken='+access_token)
					.then(result => {
						if(result.success && result.data > 0){
							uni.setTabBarBadge({
								index: 2,
								text: String(result.data)
							})
						}
					})
			}
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import './common/uni.css';
	html,body{
		background-color: #F8F8F8;
	}
	rich-text,
	.contentHtml{
		word-break: break-all;
		pre,
		.prettyprint{
			max-height: 250px;
			padding: 0 8px;
			overflow: auto;
			background-color: #F2F2F2;
		}
		img,
		.rich-img{
			width: 100%;
		}
	}
	uni-icons,
	.uni-icons{
		margin-right: 2px;
		vertical-align: -2px;
		&+.uni-icons,
		&+uni-icons{
			margin-left: 15px;
		}
	}
	uni-icons{
		vertical-align: 0px;
	}
	.empty image{
		background-image: none;
	}
	image{
		border: 1px solid #eee;
		background-image: url("static/default.png");
		background-size: 100% 100%;
	}
	button,
	uni-button{
		font-size: 16px;
		line-height: 42px;
	}
	button[type=primary],
	uni-button[type=primary]{
		background-color: $baseColor;
		&[disabled]{
			background-color: #CCCCCC;
		}
	}
	textarea{
		width: auto;
		padding: 8px 10px;
		background-color: #FFFFFF;
	}
</style>
